// components/the-popup/index.js
Component({
  externalClasses: ['custom-class'],

  options: {
    addGlobalClass: true,
    multipleSlots: true
  },

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false
    },
    duration: {
      type: Number,
      value: 300,
      optionalTypes: [String]
    },
    zIndex: {
      type: Number,
      value: 100,
      optionalTypes: [String]
    },
    overlay: {
      type: Boolean,
      value: true
    },
    position: {
      type: String,
      value: 'bottom'
    },
    round: {
      type: Boolean,
      value: false
    },
    closeOnSlideDown: {
      type: Boolean,
      value: true
    },
    overlayStyle: {
      type: String,
      value: ''
    },
    customStyle: {
      type: String,
      value: ''
    },
    style: {
      type: String,
      value: ''
    },
    closeable: {
      type: Boolean,
      value: true
    },
    closeIcon: {
      type: String,
      value: 'close-circle'
    },
    title: {
      type: String,
      value: ''
    },
    headerPos: {
      type: String,
      value: 're'
    },
    closeIconPos: {
      type: String,
      value: 'right'
    },
    leftIcon: Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    onTheEvent (e) {
      const { type } = e
      type && typeof type === 'string' && this.triggerEvent(type, e.detail)
    },
    onClickCloseIcon () {
      this.setData({
        show: false
      })
      this.triggerEvent('close')
    },
    onClickLeftIcon () {
      this.triggerEvent('leftclick')
    }
  }
})
